# 项目：python_project
# 文件：qbmtest
# 作者：WuTong
# 日期：2025/5/22,09:09
# coding:utf-8
from time import sleep

import requests

from YunDuanBossTest.tools import Util


def get_session(uname,upass):
    login_url = 'http://localhost:8080/YunDuanBoss/login/userLogin'
    login_data = {'userName': uname, 'userPass': upass, 'checkcode': '0000', 'remember': 'y'}
    session.post(url=login_url,data=login_data)
    return session

def add_choice():
    add_choice_url = 'http://localhost:8080/YunDuanBoss/exercise/addOption'
    add_choice_data = Util.read_json('../datas/conf.json')['add_choice_data']
    session.post(url=add_choice_url,data=add_choice_data)
    sleep(3)
    query_choice_sql = 'select content from exercise order by id desc'
    find_choice = Util.query(query_choice_sql)[0][0]
    return find_choice

def query_choice(find_choice):
    query_choice_url = 'http://localhost:8080/YunDuanBoss/exercise/queryExerByInfo'
    query_choice_data = {
        "pageSize":"10",
        "pageIndex":"1",
        "orientationSel":"",
        "qType":"",
        "kType":"",
        "phase":"",
        "contentInfo":f"{find_choice}"
    }
    session.post(url=query_choice_url,data=query_choice_data)


if __name__ == '__main__':
    session = requests.session()
    get_session('YD001','YunDuan123')
    find_choice = add_choice()
    query_choice(find_choice)


